<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>产品列表页</title>
<link rel="stylesheet" type="text/css"
	href="${pageContext.request.contextPath}/jquery-easyui-1.8.8/themes/default/easyui.css">
<link rel="stylesheet" type="text/css"
	href="${pageContext.request.contextPath}/jquery-easyui-1.8.8/themes/icon.css">
<link rel="stylesheet" type="text/css"
	href="${pageContext.request.contextPath}/jquery-easyui-1.8.8/themes/color.css">
<script type="text/javascript"
	src="${pageContext.request.contextPath}/jquery-easyui-1.8.8/jquery.min.js"></script>
<script type="text/javascript"
	src="${pageContext.request.contextPath}/jquery-easyui-1.8.8/jquery.easyui.min.js"></script>


</head>
<body>
	<table id="attendance_dg" title="考勤信息" class="easyui-datagrid"
		style="width: 1150px; height: 480px"
		url="${param.request.contextPath}/attendance/list"
		toolbar="attendance_toolbar" pagination="true" rownumbers="true"
		fitColumns="true" singleSelect="true">

		<div id="attendance_toolbar">
			<a href="javascript:void(0)" class="easyui-linkbutton"
				iconCls="icon-add" plain="true" onclick="newattendance()">新增</a>
		</div>

		<thead>
			<tr>
				<th field="cb" checkbox="true" align="center"></th>
				<th field="checkId" align="center" align="center">编号</th>
				<th field="stuId" width="30" formatter="stuIdFormatter"
					align="center">学号</th>
				<th field="claroomId" width="30" formatter="classroomIdFormatter"
					align="center">教室编号</th>
				<th field="times" width="50" align="center">时间</th>
				<th field="subId" width="50" formatter="subIdFormatter"
					align="center">课程名称</th>
			</tr>
		</thead>
	</table>


	<div id="attendance_dlg" class="easyui-dialog"
		style="width: 600px; height: 320px; padding: 10px 20px" closed="true"
		buttons="#attendance_dlg-buttons">
		<form id="attendance_fm" enctype="multipart/form-data" method="post">
			<div class="fitem">
				<label>学号:</label> <input id="stuId" name="stuId"
					class="easyui-validatebox">
			</div>
			<br>
			<div class="fitem">
				<label>教室编号:</label> <input id="claroomId" name="claroomId"
					class="easyui-validatebox">
			</div>
			<br>
			<div class="fitem">
				<label>考勤时间:</label><input id="times" name="times"
					class="easyui-datetimebox">
			</div>
			<br>
			<div class="fitem">
				<label>课程编号:</label> <input name="subId" class="easyui-validatebox">
			</div>

		</form>
	</div>
	<div id="attendance_dlg-buttons">
		<a href="#" class="easyui-linkbutton" iconCls="icon-ok"
			onclick="saveattendance()">保存</a> <a href="#"
			class="easyui-linkbutton" iconCls="icon-cancel"
			onclick="javascript:$('#attendance_dlg').dialog('close')">取消</a>
	</div>


	<script type="text/javascript">
		function stuIdFormatter(value, row, index) {
			return row.student.stuId;
		}

		function classroomIdFormatter(value, row, index) {
			return row.classroom.claroomId;
		}

		function subIdFormatter(value, row, index) {
			return row.subject.subName;
		}

		function newattendance() {
			$('#attendance_dlg').dialog('open').dialog('setTitle', '考勤');
			$('#attendance_fm').form('clear');
			url = '${pageContext.request.contextPath}/attendance/add';
		}

		function saveattendance() {
			$('#attendance_fm').form('submit', {
				url : url,
				onSubmit : function() {
					return $(this).form('validate');
				},
				success : function(result) {
					var result = eval('(' + result + ')');
					if (!result.success) {
						$.messager.show({
							title : '错误信息提示',
							msg : result.errorMsg
						});
					} else {
						$.messager.show({
							title : '成功信息提示',
							msg : result.errorMsg
						});
					}

					$('#attendance_dlg').dialog('close');
					$('#attendance_dg').datagrid('reload');
				}
			});
		}

		
	</script>

</body>
</html>